package com.dlc.shop.service;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.dlc.shop.bean.dto.WarehouseDTO;
import com.dlc.shop.bean.model.Warehouse;
import com.dlc.shop.bean.vo.StockPointVO;
import com.dlc.shop.bean.vo.WarehouseVO;
import com.dlc.shop.common.util.PageParam;

import java.util.List;
import java.util.stream.Stream;

/**
 * @author FrozenWatermelon
 * @date 2023-11-08 11:11:44
 */
public interface WarehouseService extends IService<Warehouse> {

    /**
     * 分页获取列表
     *
     * @param pageParam      分页参数
     * @param warehouseDTO 查询参数
     * @return 列表分页数据
     */
    IPage<WarehouseVO> page(PageParam<WarehouseVO> pageParam, WarehouseDTO warehouseDTO);

    /**
     * 根据id获取
     *
     * @param warehouseId id
     * @return
     */
    WarehouseVO getByWarehouseId(Long warehouseId);

    /**
     * 保存
     *
     * @param warehouse
     */
    WarehouseDTO insertWarehouseAndArea(WarehouseDTO warehouse);

    /**
     * 更新
     *
     * @param warehouse
     */
    void updateWarehouseAndArea(WarehouseDTO warehouse);

    /**
     * 根据id删除
     *
     * @param warehouseId id
     * @return
     */
    WarehouseVO deleteWarehouseAndArea(Long warehouseId);

    /**
     * 根据id清除缓存
     *
     * @param warehouseId 仓库id
     * @param shopId      店铺id
     * @param sysType     系统类型
     */
    void removeWarehouseCache(Long warehouseId, Long shopId, Integer sysType);

    /**
     * 根据shopId创建默认仓库
     *
     * @param shopId
     * @param sysType
     * @param phone
     * @param name
     */
    void createWarehouseByShopId(Long shopId, Integer sysType, String phone, String name);

    /**
     * 根据店铺id获取所有的供货城市id
     *
     * @param shopId
     * @param sysType
     * @param warehouseId
     * @return
     */
    List<Long> listWarehouseAreaByShopId(Long shopId, Integer sysType, Long warehouseId);

    /**
     * 获取仓库集合
     *
     * @param warehouseDTO 仓库dto
     * @return 仓库集合
     */
    List<WarehouseVO> listWarehouse(WarehouseDTO warehouseDTO);

    /**
     * 获取可配送仓库集合
     * @param warehouseDTO 仓库dto
     * @return 仓库集合
     */
    List<WarehouseVO> listCanDeliveryWarehouse(WarehouseDTO warehouseDTO);

    /**
     * 获取商家的默认仓库id
     *
     * @param shopId
     * @param sysType
     * @return
     */
    WarehouseVO getDefaultWarehouseByShopId(Long shopId, Integer sysType);

    /**
     * 获取店铺的所有仓库列表
     *
     * @param shopId
     * @param sysType
     * @return
     */
    List<WarehouseVO> listWarehouseByShopId(Long shopId, Integer sysType);

    /**
     * 初始化默认仓库
     */
    void intiWarehouse();

    /**
     * 获取默认仓库集合
     * @return 仓库集合
     */
    List<WarehouseVO> listDefaultWarehouses();

    /**
     * 根据店铺id和类型获取库存点数据
     * @param shopId
     * @param sysType
     * @return
     */
    StockPointVO getWarehousePoint(Long shopId, Integer sysType);

    /**
     * 根据sku获取对应店铺的仓库和门店列表
     * @param shopIds
     * @return
     */
    List<WarehouseVO> listWarehouseAndStationByShopIds(List<Long> shopIds);
}
